package com.zhb.controller;


import com.zhb.entity.Account;
import com.zhb.service.IAccountService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.zhb.responvo.ResponseInfo;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhb
 * @since 2021-09-09
 */
@RestController
@AllArgsConstructor
@Slf4j
public class AccountController {


    private final IAccountService accountService;

    @RequestMapping("account/getByUserId")
    public ResponseInfo<Account> getByUserId() {
        Account byId = accountService.getById(1);
        log.info("获取到的信息是：---{}", byId);
        List<Account> list = accountService.list();
        log.info("获取到的列表是：---{}", list);
        ResponseInfo<Account> responseInfo = new ResponseInfo<>();
        responseInfo.setData(byId);
        return responseInfo;
    }

    @RequestMapping("account/reduce")
    public ResponseInfo<Account> reduce(String accountCode, BigDecimal amount) {
        accountService.reduce(accountCode, amount);
        return new ResponseInfo<>();
    }

}
